package dao.impl;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;

import dao.OrderStateDao;
import dao.RowMapper;
import entity.OrderState;

public class OrderStateDaoImpl implements OrderStateDao{
	private JDBCTemplate jdbc = new JDBCTemplate();
	
	private class RowMapperImpl implements RowMapper<OrderState>{

		@Override
		public OrderState rowMapper(ResultSet rs) throws SQLException {
			return new OrderState(rs.getInt("orderStateId"), rs.getString("orderStateName"), null);
		}
		
	}
	
	@Override
	public List<OrderState> queryAllOrderState() {
		String sql = "SELECT * FROM orderstate";
		return jdbc.queryAll(sql, new RowMapperImpl());
	}

	@Override
	public OrderState queryOrderStateById(int orderStateId) {
		String sql = "SELECT * FROM orderstate WHERE orderStateId=?";
		return jdbc.queryOne(sql, new RowMapperImpl(), orderStateId);
	}

}
